package com.luhui.codereview.api

import com.luhui.codereview.dto.*
import com.luhui.codereview.token.LocalUserInfo
import com.luhui.codereview.token.ProjectInfo
import com.luhui.codereview.utils.RespBody
import retrofit2.http.*
import okhttp3.MultipartBody
import retrofit2.http.POST
import retrofit2.http.Multipart

/**
 * @author  luhui
 * @date  2019/10/27 21:33
 * @version 1.0
 */
interface CodeReviewApi {

    /**
     * code review查询列表
     */
    @GET("cr/review/getReviewCodes")
    suspend fun codeList(@Query("userId") userId:Long,@Query("projectId") projectId:Long): List<ReviewResultDto>

    /**
     * 给其他人发起一个code review
     */
    @Headers("Content-Type: application/json", "Accept: application/json")
    @POST("cr/review/save")
    suspend fun saveCodeReview(@Body codeReviewDto: CreateCodeReviewDto):Boolean

    /**
     * 保存本地用户信息
     */
    @Headers("Content-Type: application/json", "Accept: application/json")
    @POST("cr/user/saveUserInfo")
    suspend fun saveUserInfo(@Body localUserInfo:LocalUserInfo) : RespBody<Long>

    /**
     * 扫描二维码接口
     */
    @Multipart
    @POST("cr/review/analysisQRCode")
    suspend fun scanQrCode(@Part part: MultipartBody.Part,@Query("userId") userId: Long): RespBody<ScanQrCodeDto<Long>>

    /**
     * 保存项目信息
     */
    @POST("cr/project/save")
    @Headers("Content-Type: application/json", "Accept: application/json")
    suspend fun saveProjectInfo(@Body projectInfo:ProjectInfo) : RespBody<Long>

    /**
     * 获取当前项目下的用户列表
     */
    @GET("/cr/review/getUserList")
    suspend fun getUserList(@Query("projectId") projectId:Long):List<ReviewUserListDto>
}